package br.com.moxeon.layerinterface;

import java.util.HashMap;

import br.com.moxeon.control.ThrowOperationController;
import br.com.moxeon.control.operation.rules.FinancialRule;
import br.com.moxeon.model.enums.TypeThrowOperation;
import br.com.vexillum.util.SpringFactory;



public  class MoxeonFactory {

	static final String CLASS_OPERATION_SINGLE_BAIXA_DESPESA = "payableAccountDownloadRule";
	static final String CLASS_OPERATION_LANCAMENTO_AVULSO = "singleThrowRule";
	static final String CLASS_OPERATION_TRANSFERENCIA = "transferationRule";
	
	
	public static FinancialRule getOperationRule(TypeThrowOperation typeOperation, HashMap<String,Object> parameter)
	{
		FinancialRule rule = null;
		if (typeOperation == TypeThrowOperation.BAIXA_DESPESA)
		{
			 rule = (FinancialRule) SpringFactory.getInstance().getBean(CLASS_OPERATION_SINGLE_BAIXA_DESPESA);
			 rule.initRuler(parameter, TypeThrowOperation.BAIXA_DESPESA);
		}
		if (typeOperation == TypeThrowOperation.LANCAMENTO_AVULSO)
		{
			rule = (FinancialRule) SpringFactory.getInstance().getBean(CLASS_OPERATION_LANCAMENTO_AVULSO);
			rule.initRuler(parameter, TypeThrowOperation.LANCAMENTO_AVULSO);
		}
		if (typeOperation == TypeThrowOperation.TRANSFERENCIA)
		{
			rule = (FinancialRule) SpringFactory.getInstance().getBean(CLASS_OPERATION_TRANSFERENCIA);
			rule.initRuler(parameter, TypeThrowOperation.TRANSFERENCIA);
		}
		return rule;
		
	}
	
	public static Object getOperationRule(TypeThrowOperation typeOperation, HashMap<String,Object> parameter, boolean multiple)
	{
		if (multiple == false)
		{
			return getOperationRule(typeOperation, parameter);
		}
		
		if (typeOperation == TypeThrowOperation.BAIXA_DESPESA)
		{
			
		}
		return null;
		
	}
	
	public static ThrowOperationController getOperationController(TypeThrowOperation typeOperation,HashMap<String,Object> parameter)
	{
		return SpringFactory.getController("throwOperationController",ThrowOperationController.class, parameter);
	}
	
}
